import request from '@/utils/request'
import setting from '@/setting'

// 项目签到相关的请求地址
enum API {
  TEACHER_WS_URL = 'websocket/',
  TEACHERCHECKIN_URL = '/teacher/CheckIn',
  TEACHERCLOSESIGN_URL = '/teacher/closeSign',
  TEACHERGETALLSIGN_URL = '/teacher/getAllSign',
}

// 创建签到的WebSocket连接
export const createWebSocket = (token: string) => {
  const url = `${setting.baseURL}/${API.TEACHER_WS_URL}${token}`
  const ws = new WebSocket(url)
  return ws
}

// 教师发起签到
export const reqTeacherStartSign = (params: any) =>
  request.get<any, any>(API.TEACHERCHECKIN_URL, { params })

// 教师关闭签到
export const reqTeacherCloseSign = (params: any) =>
  request.get<any, any>(API.TEACHERCLOSESIGN_URL, { params })

// 教师获取所有签到信息
export const reqTeacherGetAllSign = () =>
  request.get<any, any>(API.TEACHERGETALLSIGN_URL)
